<template>
  <div class="purchase-record">
    <div class="mescroll"  ref="mescroll">
      <div v-for="(item,index) in lists" :key="index" class="item">
        <div class="left">
          <p class="title">「{{item.type_name}}」{{item.title}}</p>
          <p class="time">{{item.create_time}}</p>
        </div>
        <div class="right">{{item.total}}元</div>
      </div>
    </div>
    <div class="none" v-show="noDate">        
      <img src="@/assets/sousuomendian04.png" alt="">
      <p>暂无相关内容</p>
    </div>
  </div>
</template>

<script>
  import {purchaserecord} from '@/api/api'
  import MeScroll from 'mescroll.js'
  import 'mescroll.js/mescroll.min.css'

  export default {
    components: {
    },
    data () {
      return {
        lists:[],
        noDate: false,
      }
    },
    created () {
    },
    mounted () {
      this.mescroll = new MeScroll(this.$refs.mescroll, { 
        up: {
          callback: this.upCallback
        }
      })
    },
    methods: {
      upCallback (page) {
        purchaserecord(page.num, page.size).then((res) => {
          console.log(res)
          if (page.num == 1){
            this.lists = []
          }
          if(res.data == null){
            console.log(1)
            this.mescroll.endErr()
            return
          }
          this.$nextTick(() => {
            this.mescroll.endSuccess(res.data.data.list.length);
          })
          this.lists = this.lists.concat(res.data.data.list)
          if(this.lists.length == 0){
            this.noDate = true
          }
        }).catch((err) => {
          console.dir(err)
          this.mescroll.endErr()
        })
      }
    }
  }
</script>

<style lang="stylus" scoped>
.purchase-record
  width 100%
  height 100vh
  background-color #f5f5f5
  .mescroll
    position fixed
    top 0
    bottom 0
    height auto
    width 100vw
    overflow-x hidden
    .top-img
      float left
    .search
      float left
      width 92%
      margin-left 4%
      text-align center
      background-color #fff
      height 4.5rem
      line-height 4.5rem
      margin-top -2.25rem
      margin-bottom 1rem
      img
        display inline-block
        vertical-align middle
        width 1.6rem
      span
        display inline-block
        vertical-align middle
        font-size 1.3rem
        color #172F6D
        margin-left .5rem
  .item
    display flex
    height 7rem
    background-color #fff
    padding 0 1.6rem
    border-bottom 1px solid #e6e6e6
    &:last-child
      border none
    .left
      flex 3
      .title
        font-size 1.5rem
        color #333
        overflow hidden
        white-space nowrap
        text-overflow ellipsis
        line-height 2rem
        height 2rem
        margin-bottom .4rem
        margin-top 1.5rem
        width 25rem
        margin-left -.8rem
      .time
        color #999
        font-size 1.2rem
        line-height 1.6rem
        height 1.6rem
    .right
      flex 1
      color #333
      font-weight bold
      font-size 1.5rem
      line-height 7rem
      text-align right
  .none
    img
      position absolute
      top 20.3rem
      width 7.25rem
      left 50%
      margin-left -3.625rem
    p
      color #666
      font-size 1.3rem
      text-align center
      position absolute
      width 100%
      top 32rem
</style>
